# 基础配置
variable "host_name" {
  description = "ECS host name"
  type        = string
  default     = "ecs-host"
}

variable "image_id" {
  description = "ECS image ID"
  type        = string
  default     = "ubuntu_24_04_x64_20G_alibase_20250527.vhd"
}

variable "instance_type" {
  description = "ECS instance type"
  type        = string
  default     = "ecs.gn7i-c8g1.2xlarge"
}

variable "internet_max_bandwidth_out" {
  description = "公网出带宽上限(Mbps)"
  type        = number
  default     = 5
}

# 认证配置
variable "key_name" {
  description = "SSH密钥对名称"
  type        = string
  sensitive   = true
}

variable "password" {
  description = "ECS实例登录密码"
  type        = string
  sensitive   = true
}

# 网络配置
variable "region" {
  description = "阿里云区域"
  type        = string
  default     = "cn-beijing"
}

variable "vswitch_id" {
  description = "VSwitch ID"
  type        = string
  
  validation {
    condition     = can(regex("^vsw-", var.vswitch_id))
    error_message = "VSwitch ID必须是以'vsw-'开头的有效交换机ID"
  }
}

variable "security_group_ids" {
  description = "安全组ID列表"
  type        = list(string)
  default     = ["sg-2zedmklsb7wymw0qv3mp"]
}



# 高级配置
variable "resource_group_id" {
  description = "资源组ID"
  type        = string
  sensitive   = true
}

# 资源名称配置
variable "name" {
  description = "ECS实例名称"
  type        = string
  default     = "alyecs"  # 可以设置默认值，也可以保持为空
}

variable "instances" {
  description = "ECS实例详细配置"
  type = map(object({
    name        = string
    host_name   = string
    instance_type = string
  }))
  default = {
    web_server = {
      name        = "web-01",
      host_name   = "web01",
      instance_type = "ecs.gn7i-c8g1.2xlarge"  # 保持不变
    }
  }
}

variable "pay_type" {
  description = "实例付费类型，固定为按需付费"
  type        = string
  default     = "PostPaid"
}


